﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using IFactory;
using System.Data;
using System.Data.SqlClient;


namespace BLL
{
    public class UserMonthSummary
    {

        DataStructure dllDataStructure = new DataStructure();

        /// <summary>
        /// 预定义查询条件
        /// </summary>
        public enum field
        {
            MonthDate,
            PreMonthSummary,
            MonthSummary,
            Sponsor,
            SponsorId,
            AttachmentPath,
            Department
        }

        /// <summary>
        /// 根据查询字段查询
        /// </summary>
        /// <param name="_field">查询字段</param>
        /// <param name="_value">值</param>
        /// <returns>结果集</returns>
        public DataTable get(string _field1, string _field2, object[] _value)
        {
            string _spName = "Select_UserMonthSummary";
            if (_field1.ToString() == "MonthDate" && _field2.ToString() == "Department")
            {
                _spName += "ByMonthDateAndDepartment";
            }

            return dllDataStructure.getDataTable(_spName, _value);
        }

        /// <summary>
        /// 添加上月总结
        /// </summary>
        /// <param name="_value">传入的参数值</param>
        /// <returns>影响行数</returns>
        /// <author>grokyao</author>
        /// <date>2010-1-25</date>
        public int add(object[] _value)
        {
            string _spName = "Insert_PreUserMonthSummary";
            return dllDataStructure.getAffectRows(_spName, _value);
        }


        /// <summary>
        /// 根据id附加本月上传
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public int editAttachmentPath(object[] _value)
        {
            string _spName = "Update_UserMonthSummaryAttachmentPathById";
            return dllDataStructure.getAffectRows(_spName, _value);
        }

        /// <summary>
        /// 根据id附加上月上传
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public int editPreAttachmentPath(object[] _value)
        {
            string _spName = "Update_UserMonthSummaryPreAttachmentPathById";
            return dllDataStructure.getAffectRows(_spName, _value);
        }

        /// <summary>
        /// 根据id修改
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public int editMonthSummary(object[] _value)
        {
            string _spName = "Update_UserMonthSummaryById";
            return dllDataStructure.getAffectRows(_spName, _value);
        }

        /// <summary>
        /// 根据id查询总结
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public DataTable GetSummaryById(object[] _value)
        {
            string _spName = "Select_UserMonthSummaryById";
            return dllDataStructure.getDataTable(_spName, _value);
        }
    }
}
